package com.sdkj.recruit.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sdkj.recruit.dao.IWechatTokenDao;
import com.sdkj.recruit.service.IWechatTokenService;
import com.sdkj.recruit.wechat.AccessToken;
import com.sdkj.recruit.wechat.WechatToken;

@Service
public class WechatTokenService implements IWechatTokenService{

	@Autowired
	private IWechatTokenDao wechatToken;
	
	@Override
	public WechatToken queryTokenByAppId(String appId) {
		
		return wechatToken.queryTokenByAppId(appId);
	}

	@Override
	public void saveToken(WechatToken wt) {
		wechatToken.saveToken(wt);
	}

	@Override
	public void updataToken(String appid, AccessToken token,Date createDate) {
		
		Map<String,Object> map =new HashMap<String,Object>();
		map.put("access_token", token.getAccess_token());
		map.put("expires_in", token.getExpires_in());
		map.put("createToken", createDate);
		wechatToken.updataToken(appid,map);
	}

}
